home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / FontMancer / CDEF / Sources / app.c next >
C/C++ Source or Header  |  1996-06-21  |  996b  |  48 lines

  1. #include <Controls.h>
  2. #include <Fonts.h>
  3. #include <Windows.h>
  4. #include <Dialogs.h>
  5. #include <Resources.h>
  6.  
  7. void InitToolbox(void);
  8.  
  9. void InitToolbox(void)
  10. {
  11. InitGraf(&qd.thePort);
  12. InitFonts();
  13. FlushEvents(everyEvent,0);
  14. InitWindows();
  15. TEInit();
  16. InitDialogs(0L);
  17. InitCursor();
  18. DrawMenuBar();
  19. }
  20.  
  21.  
  22. void main ( void )
  23. {
  24. WindowPtr                 theWindow;
  25. PicHandle                buttonPic;
  26. ControlHandle             theControl;
  27. Rect                     ctrlRect;
  28. short                    itemHit;
  29. Point                    mouseLoc;
  30.  
  31. EventRecord theEvent;
  32. InitToolbox();
  33.  
  34. SetRect(&ctrlRect,10,10,42,42);
  35. theWindow=GetNewWindow(200,0L,(WindowRef)-1);
  36. buttonPic = GetPicture(128);
  37. ShowWindow(theWindow);
  38. theControl=NewControl(theWindow,&ctrlRect,"\ptest",0,0,0,1,2048,24);
  39. SetCRefCon(theControl,(long) buttonPic);
  40. ShowControl(theControl);
  41. GetMouse(&mouseLoc);
  42. while (!Button());
  43.     itemHit = TrackControl(theControl,mouseLoc,0L);
  44.     if (itemHit) SetControlValue(theControl,1);
  45. while (!Button());                     
  46. FlushEvents(everyEvent,0);
  47. ReleaseResource((Handle) buttonPic);
  48. }